1$(window).load(function() { 2 generateSlide(); 3}); 4 5function generateSlide(){ 6 $('.flexslider').flexslider({ 7 animation: "slide", 8 directionNav: false 9 }); 10} 11 12function IpWidget_HpbSlide(widgetObject) { 13 this.widgetObject = widgetObject; 14 this.prepareData = prepareData; 15 this.manageInit = manageInit; 16 this.fileUploaded = fileUploaded; 17 this.addError = addError; 18 19 function manageInit() { 20 var instanceData = this.widgetObject.data('ipWidget'); 21 var uploader = this.widgetObject.find('.ipaUpload'); 22 var options = new Object; 23 options.filterExtensions = ['jpg','gif','png']; // TODO module config ããåå¾ãã¹ã 24 uploader.ipUploadFile(options); 25 26 var container = this.widgetObject.find('.ipWidget_HpbSlide_container'); 27 var options = new Object; 28 if (instanceData.data.slides) { 29 options.slides = instanceData.data.slides; 30 } else { 31 options.slides = new Array(); 32 } 33 options.slideWidth = this.widgetObject.find('input[name="slideWidth"]').val(); 34 options.slideHeight = this.widgetObject.find('input[name="slideHeight"]').val(); 35 options.slideTemplate = this.widgetObject.find('.ipaSlideTemplate'); 36 container.ipWidget_HpbSlide_container(options); 37 38 this.widgetObject.bind('fileUploaded.ipUploadFile', this.fileUploaded); 39 this.widgetObject.bind('error.ipUploadImage' , {widgetController: this}, this.addError); 40 this.widgetObject.bind('error.ipUploadFile' , {widgetController: this}, this.addError); 41 } 42 43 function addError(event, errorMessage) { 44 $(this).trigger('error.ipContentManagement', [errorMessage]); 45 } 46 47 function fileUploaded(event, fileName) { 48 /* we are in widgetObject context */ 49 var $this = $(this); 50 var container = $this.find('.ipWidget_HpbSlide_container'); 51 container.ipWidget_HpbSlide_container('addSlide', fileName, '', ''); 52 } 53 54 function prepareData() { 55 var data = Object(); 56 var container = this.widgetObject.find('.ipWidget_HpbSlide_container'); 57 58 data.slides = new Array(); 59 $slides = container.ipWidget_HpbSlide_container('getSlides'); 60 $slides.each(function(index) { 61 var $this = $(this); 62 var tmpSlide = new Object(); 63 tmpSlide.title = $this.ipWidget_HpbSlide_slide('getTitle'); 64 tmpSlide.link = $this.ipWidget_HpbSlide_slide('getLink'); 65 tmpSlide.fileName = $this.ipWidget_HpbSlide_slide('getFileName'); 66 tmpSlide.status = $this.ipWidget_HpbSlide_slide('getStatus'); 67 var tmpCropCoordinates = $this.ipWidget_HpbSlide_slide('getCropCoordinates'); 68 tmpSlide.cropX1 = tmpCropCoordinates.x1; 69 tmpSlide.cropY1 = tmpCropCoordinates.y1; 70 tmpSlide.cropX2 = tmpCropCoordinates.x2; 71 tmpSlide.cropY2 = tmpCropCoordinates.y2; 72 data.slides.push(tmpSlide); 73 }); 74 data.blockName = this.widgetObject.find('#blockName').val(); 75 $(this.widgetObject).trigger('preparedWidgetData.ipWidget', [ data ]); 76 } 77}; 78 79(function($) { 80 var methods = { 81 init : function(options) { 82 83 return this.each(function() { 84 var $this = $(this); 85 var data = $this.data('ipWidget_HpbSlide_container'); 86 87 // If the plugin hasn't been initialized yet 88 var slides = null; 89 if (options.slides) { 90 slides = options.slides; 91 } else { 92 slides = new Array(); 93 } 94 95 if (!data) { 96 $this.data('ipWidget_HpbSlide_container', { 97 slides : slides, 98 slideTemplate : options.slideTemplate, 99 slideWidth : options.slideWidth, 100 slideHeight : options.slideHeight 101 }); 102 103 for (var i in slides) { 104 var coordinates = new Object(); 105 coordinates.cropX1 = slides[i]['cropX1']; 106 coordinates.cropY1 = slides[i]['cropY1']; 107 coordinates.cropX2 = slides[i]['cropX2']; 108 coordinates.cropY2 = slides[i]['cropY2']; 109 $this.ipWidget_HpbSlide_container('addSlide', slides[i]['SlideOriginal'], slides[i]['title'], slides[i]['link'], 'present', coordinates); 110 } 111 $this.bind('removeSlide.ipWidget_HpbSlide', function(event, slideObject) { 112 var $slideObject = $(slideObject); 113 $slideObject.ipWidget_HpbSlide_container('removeSlide', $slideObject); 114 }); 115 $( ".ipWidget_HpbSlide_container" ).sortable(); 116 $( ".ipWidget_HpbSlide_container" ).sortable('option', 'handle', '.ipaSlideMove'); 117 } 118 }); 119 }, 120 121 addSlide : function (fileName, title, link, status, coordinates) { 122 var $this = this; 123 var data = $this.data('ipWidget_HpbSlide_container'); 124 var $newSlideRecord = $this.data('ipWidget_HpbSlide_container').slideTemplate.clone(); 125 $newSlideRecord.ipWidget_HpbSlide_slide({'slideWidth' : data.slideWidth, 'slideHeight' : data.slideHeight, 'status' : status, 'fileName' : fileName, 'title' : title, 'link' : link, 'coordinates' : coordinates}); 126 var $uploader = $this.find('.ipaUpload'); 127 if ($uploader.length > 0) { 128 $($uploader).before($newSlideRecord); 129 } else { 130 $this.append($newSlideRecord); 131 } 132 }, 133 134 removeSlide : function ($slideObject) { 135 $slideObject.hide(); 136 $slideObject.ipWidget_HpbSlide_slide('setStatus', 'deleted'); 137 138 }, 139 140 getSlides : function () { 141 var $this = this; 142 return $this.find('.ipaSlideTemplate'); 143 } 144 145 }; 146 147 $.fn.ipWidget_HpbSlide_container = function(method) { 148 if (methods[method]) { 149 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 150 } else if (typeof method === 'object' || !method) { 151 return methods.init.apply(this, arguments); 152 } else { 153 $.error('Method ' + method + ' does not exist on jQuery.ipAdminWidgetButton'); 154 } 155 }; 156 157})(jQuery); 158 159(function($) { 160 var methods = { 161 init : function(options) { 162 return this.each(function() { 163 var $this = $(this); 164 var data = $this.data('ipWidget_HpbSlide_slide'); 165 var status = 'new'; 166 167 if (options.status) { 168 status = options.status; 169 } 170 // If the plugin hasn't been initialized yet 171 if (!data) { 172 var data = { 173 title : '', 174 link : '', 175 fileName : '', 176 status : status, 177 slideWidth : options.slideWidth, 178 slideHeight : options.slideHeight 179 }; 180 181 if (options.title) { 182 data.title = options.title; 183 } 184 if (options.link) { 185 data.link = options.link; 186 } 187 if (options.fileName) { 188 data.fileName = options.fileName; 189 } 190 if (options.status) { 191 data.status = options.status; 192 } 193 194 $this.data('ipWidget_HpbSlide_slide', { 195 title : data.title, 196 link : data.link, 197 fileName : data.fileName, 198 status : data.status 199 }); 200 $this.find('.ipaSlideTitle').val(data.title); 201 } 202 203 //$this.find('.ipaSlide').attr('src', ip.baseUrl + data.fileName); 204 var slideOptions = new Object; 205 slideOptions.image = data.fileName; 206 if (options.coordinates) { 207 slideOptions.cropX1 = options.coordinates.cropX1; 208 slideOptions.cropY1 = options.coordinates.cropY1; 209 slideOptions.cropX2 = options.coordinates.cropX2; 210 slideOptions.cropY2 = options.coordinates.cropY2; 211 } 212 slideOptions.windowWidth = options.slideWidth; 213 slideOptions.windowHeight = options.slideHeight; 214 slideOptions.enableChangeWidth = false;
215 slideOptions.enableChangeHeight = false; 216 slideOptions.enableScale = false; 217 slideOptions.enableFraming = false; 218 slideOptions.enableUnderscale = true; 219 slideOptions.autosizeType = 'fit'; 220 221 $this.find('.ipaSlide').ipUploadImage(slideOptions); 222 223 $this.find('.ipaSlideRemove').bind('click', 224 function(event){ 225 $this = $(this); 226 $this.trigger('removeClick.ipWidget_HpbSlide'); 227 return false; 228 } 229 ); 230 $this.find('.ipaSlideLink').bind('click', 231 function(event){ 232 $this = $(this); 233 $this.trigger('linkClick.ipWidget_HpbSlide'); 234 return false; 235 } 236 ); 237 $this.bind('removeClick.ipWidget_HpbSlide', function(event) { 238 $this.trigger('removeSlide.ipWidget_HpbSlide', this); 239 }); 240 $this.bind('linkClick.ipWidget_HpbSlide', function(event) { 241 $this = $(this); 242 var data = $this.data('ipWidget_HpbSlide_slide'); 243 var newLink; 244 // #TODO ãã¿æ¸ããããã 245 if (newLink = prompt('ãªã³ã¯å ãå ¥åãã¦ãã ãã', data.link)) { 246 data.link = newLink; 247 $this.data('ipWidget_HpbSlide_slide', data); 248 } 249 }); 250 return $this; 251 }); 252 }, 253 getTitle : function() { 254 var $this = this; 255 return $this.find('.ipaSlideTitle').val(); 256 }, 257 getLink : function() { 258 var $this = this; 259 return $this.data('ipWidget_HpbSlide_slide').link; 260 }, 261 getFileName : function() { 262 var $this = this; 263 var curImage = $this.find('.ipaSlide').ipUploadImage('getCurImage'); 264 return curImage; 265 }, 266 getCropCoordinates : function() { 267 var $this = this; 268 var ipUploadSlide = $this.find('.ipaSlide'); 269 var cropCoordinates = ipUploadSlide.ipUploadImage('getCropCoordinates'); 270 return cropCoordinates; 271 }, 272 getStatus : function() { 273 var $this = this; 274 var tmpData = $this.data('ipWidget_HpbSlide_slide'); 275 if (tmpData.status == 'deleted') { 276 return tmpData.status; 277 } 278 var ipUploadSlide = $this.find('.ipaSlide'); 279 if (tmpData.status == 'new' || ipUploadSlide.ipUploadImage('getNewImageUploaded')) { 280 return 'new'; 281 } else { 282 if (ipUploadSlide.ipUploadImage('getCropCoordinatesChanged') && ipUploadSlide.ipUploadImage('getCurImage') != false) { 283 return 'coordinatesChanged'; 284 } 285 } 286 var tmpData = $this.data('ipWidget_HpbSlide_slide'); 287 //status, set on creation. Usually 'new' or 'present' 288 return tmpData.status; 289 }, 290 setStatus : function(newStatus) { 291 var $this = $(this); 292 var tmpData = $this.data('ipWidget_HpbSlide_slide'); 293 tmpData.status = newStatus; 294 $this.data('ipWidget_HpbSlide_slide', tmpData); 295 } 296 }; 297 298 $.fn.ipWidget_HpbSlide_slide = function(method) { 299 if (methods[method]) { 300 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 301 } else if (typeof method === 'object' || !method) { 302 return methods.init.apply(this, arguments); 303 } else { 304 $.error('Method ' + method + ' does not exist on jQuery.ipAdminWidgetButton'); 305 } 306 }; 307})(jQuery); 308
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.