Changeset 1138989
- Timestamp:
- 04/20/2015 10:06:05 AM (11 years ago)
- Location:
- kraken-image-optimizer/trunk
- Files:
-
- 2 added
- 6 edited
-
css/jquery.modal.css (modified) (2 diffs)
-
js/ajax.js (modified) (3 diffs)
-
js/dist (added)
-
js/dist/kraken.min.js (added)
-
js/jquery.modal.min.js (modified) (1 diff)
-
kraken.php (modified) (4 diffs)
-
lib/Kraken.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kraken-image-optimizer/trunk/css/jquery.modal.css
r881286 r1138989 1 . modal {1 .kraken-modal { 2 2 display: none; 3 3 width: 600px; … … 15 15 box-shadow: 0 0 10px #000; 16 16 } 17 18 /* 19 .modal a.close-modal { 20 position: absolute; 21 top: -12.5px; 22 right: -12.5px; 23 display: block; 24 width: 30px; 25 height: 30px; 26 text-indent: -9999px; 27 background: url(close.png) no-repeat 0 0; 28 } 29 */ 30 31 .modal-spinner { 17 .kraken-modal-spinner { 32 18 display: none; 33 19 width: 64px; -
kraken-image-optimizer/trunk/js/ajax.js
r1128011 r1138989 156 156 .append('<br /><small class="kraken-bulk-small">The following <strong>' + nImages + '</strong> images will be optimized by Kraken.io using the <strong class="bulkSetting">' + setting + '</strong> setting:</small><br />') 157 157 .appendTo("body") 158 . modal(modalOptions)159 .bind($. modal.BEFORE_CLOSE, function(event, modal) {160 161 }) 162 .bind($. modal.OPEN, function(event, modal) {163 164 }) 165 .bind($. modal.CLOSE, function(event, modal) {158 .kmodal(modalOptions) 159 .bind($.kmodal.BEFORE_CLOSE, function(event, modal) { 160 161 }) 162 .bind($.kmodal.OPEN, function(event, modal) { 163 164 }) 165 .bind($.kmodal.CLOSE, function(event, modal) { 166 166 $("#kraken-bulk-modal").remove(); 167 167 }) … … 207 207 208 208 $(".close-kraken-bulk").click(function() { 209 $. modal.close();209 $.kmodal.close(); 210 210 }); 211 211 … … 309 309 .unbind("click") 310 310 .click(function() { 311 $. modal.close();311 $.kmodal.close(); 312 312 }); 313 313 } -
kraken-image-optimizer/trunk/js/jquery.modal.min.js
r881286 r1138989 3 3 Version 0.5.5 4 4 */ 5 !function(a){var b=null;a.modal=function(c,d){a.modal.close();var e,f;if(this.$body=a("body"),this.options=a.extend({},a.modal.defaults,d),this.options.doFade=!isNaN(parseInt(this.options.fadeDuration,10)),c.is("a"))if(f=c.attr("href"),/^#/.test(f)){if(this.$elm=a(f),1!==this.$elm.length)return null;this.open()}else this.$elm=a("<div>"),this.$body.append(this.$elm),e=function(a,b){b.elm.remove()},this.showSpinner(),c.trigger(a.modal.AJAX_SEND),a.get(f).done(function(d){b&&(c.trigger(a.modal.AJAX_SUCCESS),b.$elm.empty().append(d).on(a.modal.CLOSE,e),b.hideSpinner(),b.open(),c.trigger(a.modal.AJAX_COMPLETE))}).fail(function(){c.trigger(a.modal.AJAX_FAIL),b.hideSpinner(),c.trigger(a.modal.AJAX_COMPLETE)});else this.$elm=c,this.open()},a.modal.prototype={constructor:a.modal,open:function(){var b=this;this.options.doFade?(this.block(),setTimeout(function(){b.show()},this.options.fadeDuration*this.options.fadeDelay)):(this.block(),this.show()),this.options.escapeClose&&a(document).on("keydown.modal",function(b){27==b.which&&a.modal.close()}),this.options.clickClose&&this.blocker.click(a.modal.close)},close:function(){this.unblock(),this.hide(),a(document).off("keydown.modal")},block:function(){var b=this.options.doFade?0:this.options.opacity;this.$elm.trigger(a.modal.BEFORE_BLOCK,[this._ctx()]),this.blocker=a('<div class="jquery-modal blocker"></div>').css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",position:"fixed",zIndex:this.options.zIndex,background:this.options.overlay,opacity:b}),this.$body.append(this.blocker),this.options.doFade&&this.blocker.animate({opacity:this.options.opacity},this.options.fadeDuration),this.$elm.trigger(a.modal.BLOCK,[this._ctx()])},unblock:function(){this.options.doFade?this.blocker.fadeOut(this.options.fadeDuration,function(){a(this).remove()}):this.blocker.remove()},show:function(){this.$elm.trigger(a.modal.BEFORE_OPEN,[this._ctx()]),this.options.showClose&&(this.closeButton=a('<a href="#close-modal" rel="modal:close" class="close-modal '+this.options.closeClass+'">'+this.options.closeText+"</a>"),this.$elm.append(this.closeButton)),this.$elm.addClass(this.options.modalClass+" current"),this.center(),this.options.doFade?this.$elm.fadeIn(this.options.fadeDuration):this.$elm.show(),this.$elm.trigger(a.modal.OPEN,[this._ctx()])},hide:function(){this.$elm.trigger(a.modal.BEFORE_CLOSE,[this._ctx()]),this.closeButton&&this.closeButton.remove(),this.$elm.removeClass("current"),this.options.doFade?this.$elm.fadeOut(this.options.fadeDuration):this.$elm.hide(),this.$elm.trigger(a.modal.CLOSE,[this._ctx()])},showSpinner:function(){this.options.showSpinner&&(this.spinner=this.spinner||a('<div class="'+this.options.modalClass+'-spinner"></div>').append(this.options.spinnerHtml),this.$body.append(this.spinner),this.spinner.show())},hideSpinner:function(){this.spinner&&this.spinner.remove()},center:function(){this.$elm.css({position:"fixed",top:"50%",left:"50%",marginTop:-(this.$elm.outerHeight()/2),marginLeft:-(this.$elm.outerWidth()/2),zIndex:this.options.zIndex+1})},_ctx:function(){return{elm:this.$elm,blocker:this.blocker,options:this.options}}},a.modal.prototype.resize=a.modal.prototype.center,a.modal.close=function(a){if(b){a&&a.preventDefault(),b.close();var c=b.$elm;return b=null,c}},a.modal.resize=function(){b&&b.resize()},a.modal.isActive=function(){return b?!0:!1},a.modal.defaults={overlay:"#000",opacity:.75,zIndex:1,escapeClose:!0,clickClose:!0,closeText:"Close",closeClass:"",modalClass:"modal",spinnerHtml:null,showSpinner:!0,showClose:!0,fadeDuration:null,fadeDelay:1},a.modal.BEFORE_BLOCK="modal:before-block",a.modal.BLOCK="modal:block",a.modal.BEFORE_OPEN="modal:before-open",a.modal.OPEN="modal:open",a.modal.BEFORE_CLOSE="modal:before-close",a.modal.CLOSE="modal:close",a.modal.AJAX_SEND="modal:ajax:send",a.modal.AJAX_SUCCESS="modal:ajax:success",a.modal.AJAX_FAIL="modal:ajax:fail",a.modal.AJAX_COMPLETE="modal:ajax:complete",a.fn.modal=function(c){return 1===this.length&&(b=new a.modal(this,c)),this},a(document).on("click.modal",'a[rel="modal:close"]',a.modal.close),a(document).on("click.modal",'a[rel="modal:open"]',function(b){b.preventDefault(),a(this).modal()})}(jQuery); 5 (function($) { 6 7 var current = null; 8 9 $.kmodal = function(el, options) { 10 $.kmodal.close(); // Close any open modals. 11 var remove, target; 12 this.$body = $('body'); 13 this.options = $.extend({}, $.kmodal.defaults, options); 14 this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10)); 15 if (el.is('a')) { 16 target = el.attr('href'); 17 //Select element by id from href 18 if (/^#/.test(target)) { 19 this.$elm = $(target); 20 if (this.$elm.length !== 1) return null; 21 this.open(); 22 //AJAX 23 } else { 24 this.$elm = $('<div>'); 25 this.$body.append(this.$elm); 26 remove = function(event, modal) { modal.elm.remove(); }; 27 this.showSpinner(); 28 el.trigger($.kmodal.AJAX_SEND); 29 $.get(target).done(function(html) { 30 if (!current) return; 31 el.trigger($.kmodal.AJAX_SUCCESS); 32 current.$elm.empty().append(html).on($.kmodal.CLOSE, remove); 33 current.hideSpinner(); 34 current.open(); 35 el.trigger($.kmodal.AJAX_COMPLETE); 36 }).fail(function() { 37 el.trigger($.kmodal.AJAX_FAIL); 38 current.hideSpinner(); 39 el.trigger($.kmodal.AJAX_COMPLETE); 40 }); 41 } 42 } else { 43 this.$elm = el; 44 this.$body.append(this.$elm); 45 this.open(); 46 } 47 }; 48 49 $.kmodal.prototype = { 50 constructor: $.kmodal, 51 52 open: function() { 53 var m = this; 54 if(this.options.doFade) { 55 this.block(); 56 setTimeout(function() { 57 m.show(); 58 }, this.options.fadeDuration * this.options.fadeDelay); 59 } else { 60 this.block(); 61 this.show(); 62 } 63 if (this.options.escapeClose) { 64 $(document).on('keydown.modal', function(event) { 65 if (event.which == 27) $.kmodal.close(); 66 }); 67 } 68 if (this.options.clickClose) this.blocker.click($.kmodal.close); 69 }, 70 71 close: function() { 72 this.unblock(); 73 this.hide(); 74 $(document).off('keydown.modal'); 75 }, 76 77 block: function() { 78 var initialOpacity = this.options.doFade ? 0 : this.options.opacity; 79 this.$elm.trigger($.kmodal.BEFORE_BLOCK, [this._ctx()]); 80 this.blocker = $('<div class="jquery-modal blocker"></div>').css({ 81 top: 0, right: 0, bottom: 0, left: 0, 82 width: "100%", height: "100%", 83 position: "fixed", 84 zIndex: this.options.zIndex, 85 background: this.options.overlay, 86 opacity: initialOpacity 87 }); 88 this.$body.append(this.blocker); 89 if(this.options.doFade) { 90 this.blocker.animate({opacity: this.options.opacity}, this.options.fadeDuration); 91 } 92 this.$elm.trigger($.kmodal.BLOCK, [this._ctx()]); 93 }, 94 95 unblock: function() { 96 if(this.options.doFade) { 97 this.blocker.fadeOut(this.options.fadeDuration, function() { 98 $(this).remove(); 99 }); 100 } else { 101 this.blocker.remove(); 102 } 103 }, 104 105 show: function() { 106 this.$elm.trigger($.kmodal.BEFORE_OPEN, [this._ctx()]); 107 if (this.options.showClose) { 108 this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>'); 109 this.$elm.append(this.closeButton); 110 } 111 this.$elm.addClass(this.options.modalClass + ' current'); 112 this.center(); 113 if(this.options.doFade) { 114 this.$elm.fadeIn(this.options.fadeDuration); 115 } else { 116 this.$elm.show(); 117 } 118 this.$elm.trigger($.kmodal.OPEN, [this._ctx()]); 119 }, 120 121 hide: function() { 122 this.$elm.trigger($.kmodal.BEFORE_CLOSE, [this._ctx()]); 123 if (this.closeButton) this.closeButton.remove(); 124 this.$elm.removeClass('current'); 125 126 if(this.options.doFade) { 127 this.$elm.fadeOut(this.options.fadeDuration); 128 } else { 129 this.$elm.hide(); 130 } 131 this.$elm.trigger($.kmodal.CLOSE, [this._ctx()]); 132 }, 133 134 showSpinner: function() { 135 if (!this.options.showSpinner) return; 136 this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>') 137 .append(this.options.spinnerHtml); 138 this.$body.append(this.spinner); 139 this.spinner.show(); 140 }, 141 142 hideSpinner: function() { 143 if (this.spinner) this.spinner.remove(); 144 }, 145 146 center: function() { 147 this.$elm.css({ 148 position: 'fixed', 149 top: "50%", 150 left: "50%", 151 marginTop: - (this.$elm.outerHeight() / 2), 152 marginLeft: - (this.$elm.outerWidth() / 2), 153 zIndex: this.options.zIndex + 1 154 }); 155 }, 156 157 //Return context for custom events 158 _ctx: function() { 159 return { elm: this.$elm, blocker: this.blocker, options: this.options }; 160 } 161 }; 162 163 //resize is alias for center for now 164 $.kmodal.prototype.resize = $.kmodal.prototype.center; 165 166 $.kmodal.close = function(event) { 167 if (!current) return; 168 if (event) event.preventDefault(); 169 current.close(); 170 var that = current.$elm; 171 current = null; 172 return that; 173 }; 174 175 $.kmodal.resize = function() { 176 if (!current) return; 177 current.resize(); 178 }; 179 180 // Returns if there currently is an active modal 181 $.kmodal.isActive = function () { 182 return current ? true : false; 183 } 184 185 $.kmodal.defaults = { 186 overlay: "#000", 187 opacity: 0.75, 188 zIndex: 1, 189 escapeClose: true, 190 clickClose: true, 191 closeText: 'Close', 192 closeClass: '', 193 modalClass: "kraken-modal", 194 spinnerHtml: null, 195 showSpinner: true, 196 showClose: true, 197 fadeDuration: null, // Number of milliseconds the fade animation takes. 198 fadeDelay: 1.0 // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.) 199 }; 200 201 // Event constants 202 $.kmodal.BEFORE_BLOCK = 'modal:before-block'; 203 $.kmodal.BLOCK = 'modal:block'; 204 $.kmodal.BEFORE_OPEN = 'modal:before-open'; 205 $.kmodal.OPEN = 'modal:open'; 206 $.kmodal.BEFORE_CLOSE = 'modal:before-close'; 207 $.kmodal.CLOSE = 'modal:close'; 208 $.kmodal.AJAX_SEND = 'modal:ajax:send'; 209 $.kmodal.AJAX_SUCCESS = 'modal:ajax:success'; 210 $.kmodal.AJAX_FAIL = 'modal:ajax:fail'; 211 $.kmodal.AJAX_COMPLETE = 'modal:ajax:complete'; 212 213 $.fn.kmodal = function(options){ 214 if (this.length === 1) { 215 current = new $.kmodal(this, options); 216 } 217 return this; 218 }; 219 220 // Automatically bind links with rel="modal:close" to, well, close the modal. 221 $(document).on('click.modal', 'a[rel="modal:close"]', $.kmodal.close); 222 $(document).on('click.modal', 'a[rel="modal:open"]', function(event) { 223 event.preventDefault(); 224 $(this).kmodal(); 225 }); 226 })(jQuery); -
kraken-image-optimizer/trunk/kraken.php
r1128378 r1138989 22 22 * Description: This plugin allows you to optimize your WordPress images through the Kraken API, the world's most advanced image optimization solution. 23 23 * Author: Karim Salman 24 * Version: 1.0. 825 * Stable Tag: 1.0. 824 * Version: 1.0.9 25 * Stable Tag: 1.0.9 26 26 * Author URI: https://kraken.io 27 27 * License GPL2 … … 31 31 if ( !class_exists( 'Wp_Kraken' ) ) { 32 32 33 define( 'KRAKEN_DEV_MODE', false ); 33 34 class Wp_Kraken { 34 35 … … 41 42 private $optimization_type = 'lossy'; 42 43 43 public static $kraken_plugin_version = '1.0. 8';44 public static $kraken_plugin_version = '1.0.9'; 44 45 45 46 function __construct() { … … 135 136 if ( $hook == 'options-media.php' || $hook == 'upload.php') { 136 137 wp_enqueue_script( 'jquery' ); 137 wp_enqueue_script( 'tipsy-js', plugins_url( '/js/jquery.tipsy.js', __FILE__ ), array( 'jquery' ) ); 138 wp_enqueue_script( 'async-js', plugins_url( '/js/async.js', __FILE__ ) ); 139 wp_enqueue_script( 'ajax-script', plugins_url( '/js/ajax.js', __FILE__ ), array( 'jquery' ) ); 138 if ( KRAKEN_DEV_MODE === true ) { 139 wp_enqueue_script( 'async-js', plugins_url( '/js/async.js', __FILE__ ) ); 140 wp_enqueue_script( 'tipsy-js', plugins_url( '/js/jquery.tipsy.js', __FILE__ ), array( 'jquery' ) ); 141 wp_enqueue_script( 'modal-js', plugins_url( '/js/jquery.modal.min.js', __FILE__ ), array( 'jquery' ) ); 142 wp_enqueue_script( 'ajax-script', plugins_url( '/js/ajax.js', __FILE__ ), array( 'jquery' ) ); 143 wp_localize_script( 'ajax-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); 144 wp_localize_script( 'ajax-script', 'kraken_settings', $this->kraken_settings ); 145 } else { 146 wp_enqueue_script( 'kraken-js', plugins_url( '/js/dist/kraken.min.js', __FILE__ ), array( 'jquery' ) ); 147 wp_localize_script( 'kraken-js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); 148 wp_localize_script( 'kraken-js', 'kraken_settings', $this->kraken_settings ); 149 } 140 150 wp_enqueue_style( 'kraken_admin_style', plugins_url( 'css/admin.css', __FILE__ ) ); 141 151 wp_enqueue_style( 'tipsy-style', plugins_url( 'css/tipsy.css', __FILE__ ) ); 142 152 wp_enqueue_style( 'modal-style', plugins_url( 'css/jquery.modal.css', __FILE__ ) ); 143 wp_localize_script( 'ajax-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );144 wp_localize_script( 'ajax-script', 'kraken_settings', $this->kraken_settings );145 wp_enqueue_script( 'modal-js', plugins_url( '/js/jquery.modal.min.js', __FILE__ ), array( 'jquery' ) );146 153 } 147 154 } -
kraken-image-optimizer/trunk/lib/Kraken.php
r1128009 r1138989 5 5 6 6 protected $auth = array(); 7 public static $kraken_plugin_version = '1.0. 8';7 public static $kraken_plugin_version = '1.0.9'; 8 8 9 9 public function __construct($key = '', $secret = '') -
kraken-image-optimizer/trunk/readme.txt
r1128009 r1138989 5 5 Tested up to: 4.1 6 6 Donate link: https://kraken.io 7 Stable tag: 1.0. 87 Stable tag: 1.0.9 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html … … 95 95 == Changelog == 96 96 97 = 1.0.9 = 98 * Fixed potential conflict with Bootstrap Modal on blogs using Twitter Bootstrap. 99 * Better bundling of scripts for faster loading of the plugin. 100 97 101 = 1.0.8 = 98 102 * Added the ability to control the number of images the bulk tool optimizes at once. The default settings of 4 is recommended. Blogs with limited resources, for example those on small shared hosting plans should try a lower value if they run into issues with bulk optimization. Blogs on larger hosting plans can experiment with higher values.
Note: See TracChangeset
for help on using the changeset viewer.