Guest User

Untitled

a guest
Aug 31st, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dojo.require('dojox.gfx');
  2. dojo.require('dojox.gfx.utils');
  3. dojo.require('dojox.gfx.move');
  4. var on = dojo.require("dojo/on");
  5. console.log(on);
  6. dojo.require("dojo/query!css2");
  7. var cardTemplate = '{{=it.template}}';
  8. console.log(cardTemplate);
  9.  
  10. /* Set the init function to run when dojo loading and page parsing has completed. */
  11. dojo.ready(function(){
  12.  
  13.   /* Create our surface. */
  14.     var drawing = dojox.gfx.createSurface(dojo.byId("dojo-object"), 340, 210);
  15.     drawing
  16.         .rawNode
  17.         .style
  18.         .backgroundImage = 'url(https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSCPAq1XniWl2D5Ca1-AtWRKHRRmUh4KX5SQAtgOZTL9tQeKijs_wrPnuM)';
  19.  
  20.     drawing
  21.         .rawNode
  22.         .style
  23.         .backgroundRepeat = 'no-repeat';
  24.  
  25.     drawing
  26.         .rawNode
  27.         .style
  28.         .backgroundSize = '100% auto';
  29.  
  30.     var controlsModule = DrawControlsModuleInit();
  31.     drawModule.init(jQuery, dojox, drawing);
  32.  
  33.     var square = controlsModule.newSquareControl(10, 10, 10, 10, 'black', 'red');
  34.  
  35.     drawing.createImage(
  36.         {
  37.             width: 150,
  38.             height: 100,
  39.             src: 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSCPAq1XniWl2D5Ca1-AtWRKHRRmUh4KX5SQAtgOZTL9tQeKijs_wrPnuM',
  40.         });
  41.  
  42.     drawing.createRect(square)
  43.         .setFill('blue')
  44.         .x = 150;
  45.  
  46.     var t = drawing.createText({
  47.         text: 'Lorem ipsum',
  48.         align: 'start',
  49.         x: 10,
  50.         y: 20
  51.     });
  52.  
  53.     t.rawNode.className = 'moveable';
  54.  
  55.     t.setFill('black');
  56.     t.setFont({
  57.         family: 'Arial',
  58.         size: 15
  59.     });
  60.  
  61.     t = new dojox.gfx.Moveable(t);
  62.  
  63.  
  64.   /*var rect = drawing.createRect({
  65.    width:  100,
  66.    height: 100,
  67.    x: 50,
  68.    y: 50
  69.  }).setFill("blue").setStroke("black");*/
  70.  
  71.     $('#button').on('click', function(event) {
  72.         event.preventDefault();
  73.         var json = dojox.gfx.utils.toJson(drawing);
  74.         console.log(json);
  75.         dojox.gfx.utils.fromJson(drawing, json);
  76.         console.log(drawing.children);
  77.         for (var i = 0; i < drawing.children.length; i++) {
  78.             new dojox.gfx.Moveable(drawing.children[i]);
  79.         }
  80.         console.log('clicked');
  81.     });
  82. });
Advertisement
Add Comment
Please, Sign In to add comment